package com.ganbo.stock.repository;

import com.ganbo.stock.entity.StockIdea;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface StockIdeaRepository extends JpaRepository<StockIdea, Long> {


    @Query("delete  from StockIdea  o where o.stockId = ?1")
    @Modifying
    void deleteByStockId(Long stockId);

    List<StockIdea> findByStockId(Long stockId);

    @Query("select o.ideaName from StockIdea  o  where o.stockId = ?1 ")
    List<String> findIdNamesByStockId(Long stockId);

    @Query("delete  from StockIdea  o where o.stockDm = ?1 and o.ideaName = ?2 ")
    @Modifying
    void deleteStockIdeaByStockDmAndIdeaName(String dm, String ideaName);

}
